#ifndef VERTEX_H
#define VERTEX_H

class   Face;
class Triangle;
class   Shader;
#include "Troll3D_global.h"
#include "BufferObject.h"
#include "GeoTool/vec4.h"
#include "Attributes.h"
#include "Attribute.h"
#include "VertexTemplate.h"
#include "Triangle.h"

#include <memory.h>
#include <vector>

using namespace std;

/*!	@brief The Vertex class define the structure of vertex attributes send to the shaders, and the way to interact with them
 *
 *          Workflow overview : A mesh is constitued by vertices. All the vertex a Mesh need will be stored in only one
 *          vector : the static propertie Vertices in Vertex.
 *          When a mesh want to create a new Vertex, it'll have to call the static method "New", this will automatically add the vertex
 *          in the Vertices vector, and give back a pointer for the mesh
 *          To render the scene, the vertex must be given to a VBO as float *. So, there'll be a phase where all the vertex will be
 *          inspected and transformed in float * . During this phase, the m_Indice must be defined, for the IBO to work correctly
 */

class TROLL3DSHARED_EXPORT Vertex
{
    public :

        /************************************************
        /*				Public
        /************************************************/

            /************************************************
            /*				Constructors
            /************************************************/

                Vertex();

            /************************************************
            /*				Methods
            /************************************************/

                void UpdateVertex();
                vector<AttributeTemplate*>& Attributes();

                void SetTemplate(VertexTemplate * vertexTemplate);

                bool SetAttribute(string name, float x);
                bool SetAttribute(string name, float x, float y);
                bool SetAttribute(string name, float x, float y, float z);
                bool SetAttribute(string name, float x, float y, float z, float w);

                bool SetAttribute(int pos, float x);
                bool SetAttribute(int pos, float x, float y);
                bool SetAttribute(int pos, float x, float y, float z);
                bool SetAttribute(int pos, float x, float y, float z, float w);

                void InsertVertexBuffer();



                /*!	@brief The ComputeNormal method, as the name imply, will compute the normal of a vertex by making the means of all connected faces normals	*/
                void        ComputeNormal();

            /************************************************/
            /*				Properties 						*/
            /************************************************/

                int                     vertexId;

                int                     offset;
                int                     size;
                int                     attributeCount;

                VertexTemplate *        vertexTemplate;

                vector<Triangle *>      m_Triangles;
                unsigned short          m_Index;            /*!< Index of the vertex, used by face to construct IBO and must be
                                                                 *   defined during float * construction         */


        /************************************************/
        /*				Statics 						*/
        /************************************************/

            /************************************************/
            /*				Properties 						*/
            /************************************************/

                static vector<GLfloat>  s_Vertices;

            /************************************************/
            /*				Methods 						*/
            /************************************************/

                void AddVertex(Vertex * vertex);

                static float * Array();
                static void Print();



                /*! All the static new function will be used to create Vertex inside meshes */




};

#endif
